<?php
/**
 *@author Connor <caokang@foxmail.com>
 *@todo
 *@link www.zeevin.com
 */

?>
<div class="title">
      	<ul style="float:left;">
      		<li <?php if($_GET['b']=='1'):?>class="current"<?php endif;?>><a href="?r=home/friend&b=1" title="我的好友">我的好友</a></li>
      		<li <?php if($_GET['b']=='2'):?>class="current"<?php endif;?>><a href="?r=home/friend&s=1&b=2" title="我关注的">我关注的</a></li>
      		<li <?php if($_GET['b']=='3'):?>class="current"<?php endif;?>><a href="?r=home/friend&s=2&b=3" title="关注我的">关注我的</a></li>
      		<li <?php if($_GET['b']=='4'):?>class="current"<?php endif;?>><a href="?r=home/blist&b=4" title="黑名单">黑名单</a></li>
      	</ul>
</div>
      <div class="main_content">
      	<div class="friends">
      		<div class="friends_list">
      			<ul>
      				<?php if(count($friends['rows'])):
      					foreach($friends['rows'] as $v):
                                          $tmp=($v->uid==Yii::app()->user->id)?$v->fid:$v->uid;
                                          $user = User::model()->findByPk($tmp);
                                    ?>
      				<li> <a href="#" title="<?php echo $user->nickname;?>"><img src="<?php echo Utils::getAvatar($user->avatar);?>" width="120" height="120" alt="<?php echo $user->nickname;?>"/></a>
      					<p class="friend_name"><?php 
      					?></p>
      					<p class="friend_info"><?php echo User::getSex($user->sex),'，',Utils::getAge($user->birth),'，',Area::getName($user->city_id);?></p>
      					<p class="friend_but"><span type="refollow" class="add_attention doset" tag="<?php echo $tmp;?>">取消关注</span><span type="black" class="add_blacklist doset" tag="<?php echo $tmp;?>">拉黑名单</span></p>
      				</li>
      				<?php endforeach;else:?>
      				<li> 
      					<p class="friend_name">无信息</p>
      				</li>
      				<?php endif?>

      				
      			</ul>
      		</div>
      		<div class="page">
      			<?php $this->widget('ZLinkPager', array('pages' => $friends['pages'])); ?>
      		</div>
      	</div>
      </div>
<script type="text/javascript">
$(document).ready(function(){
      $('.doset').click(function(){
            
            var type = $(this).attr('type');
            var content = "√ 已取消";
            if(type=='black')content = "√ 已拖黑";
            $(this).toggleClass("color1");
            $(this).text(content).addClass("color2");
            $.post('?r=home/set',{act:type,id:$(this).attr('tag')},
                  function(data){
                        data = $.parseJSON(data);
                        if(data.status!='0'){
                              alert(data.desc);
                        }
                  })
      });

})
</script>